#define _CRT_SECURE_NO_WARNINGS 1
int cmp(const void* a, const void* b)
{
    return (*(int*)a - *(int*)b);
}
int majorityElement(int* nums, int numsSize) {
    if (numsSize == 1) return nums[0];
    qsort(nums, numsSize, sizeof(int), cmp);
    int i = 1, count = 1;
    for (i; i < numsSize; i++) {
        if (nums[i] == nums[i - 1]) {
            count++;
        }
        else {
            count = 1;
        }
        if (count > numsSize / 2)
            return nums[i];
    }
    return 0;
}